#pragma once
#ifndef MessageQueue_h__
#define MessageQueue_h__

#include <mutex>
#include <memory>
#include <queue>
#include "Message.h"
#include "ThreadPool.h"

class CMessageQueue
{
public:
	CMessageQueue(const CMessageQueue&) = delete;
	CMessageQueue& operator=(const CMessageQueue&) = delete;

	static std::shared_ptr<CMessageQueue> getInstance();
	int addMessage(const int, const char*, const CBasicHandler*);
	CMessage getMessage();
	bool empty();
	int getSize()
	{
		return m_queue.size();
	}

	void setThreadPool(const std::shared_ptr<ThreadPool>& threadpool)
	{
		m_pThreadPool = threadpool;
	}

private:
	CMessageQueue()
		: m_pThreadPool(nullptr)
	{}

private:
	static std::shared_ptr<CMessageQueue> p_MessageQueue;
	static std::mutex queue_mutex;

	std::queue<CMessage> m_queue;
	std::shared_ptr<ThreadPool> m_pThreadPool;
};

#endif // MessageQueue_h__
